// 施工 底部导航

<template id="v-navber-construction">
    <f7-viewbar slot="fixed"
                class="f7-link">
        <f7-link v-for="(item, i) in links"
                 :key="i"
                 :icon-f7="item.icon"
                 :text="item.text"
                 href="#"
                 @click="link(item.href)"
                 :tab-link-active="item.tabLinkActive"></f7-link>
    </f7-viewbar>
</template>
<script>
import Config from "../../config";
export default {
    data () {
        return {

        }
    },
    computed: {
        links () {
            let arr = [
                {
                    text: "首页",
                    icon: "house",
                    href: "/business/qzjx/index",
                    // href: "/business/construction/home/index",
                    tabLinkActive: true,
                },

                // {
                //     text: "项目沙盘",
                //     class: "iconfont icon-shuzijiankong",
                //     href: "/business/construction/sandTable/index",
                //     tabLinkActive: false,
                // },
                // {
                //   text: "数字监控",
                //   class: "iconfont icon-a-bianzu11",
                //   href: "/business/construction/build/digitalMonitoring/index",
                //   tabLinkActive: false,
                // },
                {
                    text: "我的",
                    icon: "person",
                    href: "/ui/set/index",
                    tabLinkActive: false,
                },
            ]

            // if (!window.plus) {
            //     // 方面h5测试的 正式不需要这个入口
            //     arr.push({
            //         text: "我的",
            //         class: "iconfont icon-gongcheng",
            //         href: "/ui/set/index",
            //         tabLinkActive: false,
            //     })
            // }

            let url = this.$f7route.path;
            if (url == "/") {
                url = Config.pages.home;
            }
            arr.map(item => {
                item.tabLinkActive = this.fillUrl(item.href) == this.fillUrl(url)
            })

            // 角色分配路
            let role=['SUPE_MANAGER','DISCIPLINE_SUPERVISOR','CONS_MANAGER','CONSTRUCTION_TEC_MANAGER','CONSTRUCTION_SAFETY_SPECIALIST','SUPPLIER_PERSON']
            // 因为hasRole进行了把数据小写，所以这边也需要对应的小写
            role=role.map(item=>{
                item=item.toLowerCase()
                return item
            })
            // 过滤出底部路由
            if(this.$framework.account.hasRole(role)){
                arr=arr.filter(item=>{
                    return item.text!='数字监控' && item.text!='项目沙盘'
                })
            }else  if(this.$framework.account.hasRole("IOS_ROLE")){//IOS 审核专用
              arr=arr.filter(item=>{
                return item.text!='项目沙盘';
              })
            }

            return arr
        }
    },
    methods: {
        fillUrl (url) {
            let r = url;
            if (!this.$util.startsWith(r, "/")) {
                r = "/" + r;
            }
            if (!this.$util.endsWith(r, "/")) {
                r = r + "/";
            }
            return r;
        },
        link (url) {
            this.$f7.views.current.router.navigate(url, { animate: false });
        },
    },
    mounted () {
        // var url = this.$f7route.path;
        // if (url == "/") {
        //     url = Config.pages.home;
        // }
        // this.$util.each(this.links, (c) => {
        //     c.tabLinkActive = this.fillUrl(c.href) == this.fillUrl(url);
        // });
        // this.links.map(item => {
        //     item.tabLinkActive = this.fillUrl(c.href) == this.fillUrl(url)
        // })
    },
};
</script>
<style lang="less" scoped>
.f7-link::after {
    display: none;
}
.f7-link::before {
    display: none;
}
.f7-link {
    background-color: #ffffff;
    //height: calc(106px * var(--ratio));
    box-shadow: 2px -4px 20px 3px #0000000a;
}
/deep/ .link i + span {
    margin-left: 0px;
    margin-top: 4px;
}
</style>
